#ifndef __UART__WIFI_H_
#define __UART__WIFI_H_

#include "uart_app.h"

/**
 ****************************************************************************************************
 * DONE 用户变量区
 ****************************************************************************************************
 */

#define      BUFF_MAX      526

//-----------------------------------------------	

typedef struct __WIFI{
	  uint8_t  BUFF[BUFF_MAX];
	  uint8_t  buff_length;
	  uint8_t  buff_flag;
}WIFI;

typedef struct ____GPS{
	uint8_t  Frame_Buffer[BUFF_MAX];
	uint8_t  buff_length;
	uint8_t  buff_flag;
	char UTCTime[12];
	char GPS_Status[10];
	char GPS_lat[12];
	char GPS_ulat[10];
	char GPS_lon[12];
	char GPS_ulon[10];
	char GPS_spd[10];
	char GPS_cog[10];
	char GPS_date[10];
}GPS;

//-----------------------------------------------	



//-----------------------------------------------	

extern WIFI wifi;

extern GPS  gps;
/**
 ****************************************************************************************************
 * DONE 用户函数区
 ****************************************************************************************************
 */

/**
 * @if Eng 
 * @brief Clears the WiFi communication buffer memory 
 * @param None
 * @result WiFi buffer is reset to initial state
 * @else
 * @brief 清除WiFi通信缓冲区内存 
 * @param 无 
 * @result WiFi缓冲区被重置为初始状态
 * @endif 
 */
void WIFI_BUFF_MEMSET(void);

/**
 * @if Eng 
 * @brief Sends data through WiFi UART interface 
 * @param huart - Pointer to UART handle structure
 * @param data - Pointer to data buffer to be sent 
 * @result Data is transmitted via WiFi UART
 * @else
 * @brief 通过WiFi UART接口发送数据 
 * @param huart - 指向UART句柄结构的指针
 * @param data - 指向要发送的数据缓冲区的指针
 * @result 数据通过WiFi UART传输
 * @endif 
 */
void WIFI_SEND(UART_HandleTypeDef  *huart,uint8_t *data);

/**
 * @if Eng
 * @brief Checks for WiFi command acknowledgment
 * @param cmd - Command string to check acknowledgment for
 * @param dest - Buffer to store the acknowledgment response 
 * @param timeout - Maximum time to wait for acknowledgment (in ms)
 * @return 1 if acknowledgment received, 0 if timeout occurred 
 * @else 
 * @brief 检查WiFi命令确认 
 * @param cmd - 要检查确认的命令字符串 
 * @param dest - 存储确认响应的缓冲区 
 * @param timeout - 等待确认的最大时间（毫秒）
 * @return 1表示收到确认，0表示超时 
 * @endif 
 */
uint8_t WIFI_CheckAck(char* cmd, char* dest, int timeout);

/**
 * @if Eng
 * @brief Establishes TCP connection with specified credentials
 * @param id - Pointer to connection ID/username
 * @param password - Pointer to connection password
 * @result TCP connection is established
 * @else
 * @brief 使用指定凭据建立TCP连接
 * @param id - 指向连接ID/用户名的指针
 * @param password - 指向连接密码的指针
 * @result TCP连接建立 
 * @endif 
 */
void CONNECT_TO_TCP(uint8_t* id,uint8_t *password);

/**
 * @if Eng
 * @brief Establishes UDP connection with specified credentials
 * @param id - Pointer to connection ID/username
 * @param password - Pointer to connection password
 * @result UDP connection is established
 * @else
 * @brief 使用指定凭据建立UDP连接 
 * @param id - 指向连接ID/用户名的指针 
 * @param password - 指向连接密码的指针 
 * @result UDP连接建立
 * @endif 
 */
void CONNECT_TO_UDP(uint8_t* id,uint8_t *password);

/**
 * @if Eng
 * @brief Establishes MQTT connection with specified credentials 
 * @param id - Pointer to client ID/username
 * @param password - Pointer to connection password
 * @result MQTT connection is established
 * @else
 * @brief 使用指定凭据建立MQTT连接 
 * @param id - 指向客户端ID/用户名的指针 
 * @param password - 指向连接密码的指针 
 * @result MQTT连接建立
 * @endif 
 */
void CONNECT_TO_MQTT(uint8_t* id,uint8_t *password);

/**
 * @if Eng
 * @brief Configures C511 module for TCP communication 
 * @param IP - Pointer to target IP address string 
 * @param PORT - Pointer to target port number string 
 * @result C511 module is configured for TCP communication 
 * @else 
 * @brief 配置C511模块进行TCP通信 
 * @param IP - 指向目标IP地址字符串的指针 
 * @param PORT - 指向目标端口号字符串的指针 
 * @result C511模块配置为TCP通信
 * @endif 
 */
void C511_TO_TCP(uint8_t* IP ,uint8_t *PORT);

/**
 * @if Eng
 * @brief Configures C511 module for UDP communication
 * @param IP - Pointer to target IP address string
 * @param PORT - Pointer to target port number string
 * @result C511 module is configured for UDP communication
 * @else
 * @brief 配置C511模块进行UDP通信 
 * @param IP - 指向目标IP地址字符串的指针 
 * @param PORT - 指向目标端口号字符串的指针 
 * @result C511模块配置为UDP通信 
 * @endif 
 */
void C511_TO_UDP(uint8_t* IP ,uint8_t *PORT);

/**
 * @if Eng
 * @brief Configures C511 module for MQTT communication 
 * @param None
 * @result C511 module is configured for MQTT communication
 * @else
 * @brief 配置C511模块进行MQTT通信 
 * @param 无 
 * @result C511模块配置为MQTT通信 
 * @endif 
 */ 
void C511_TO_MQTT(void);

#endif

